import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.event.KeyEvent;
import java.util.Random;

/**
 * @Author: swh
 * @Description:
 * @Date: 2021/2/3 16:21
 * @Version: 1.0
 */
public class qq {

    private static int VK_A;

    public static void main(String[] args) throws AWTException {

        String[] sentence = new String[]{"VK_A", "VK_B", "VK_C", "VK_D", "VK_E"};


//        String sentence = "123456789";// 定义要发送的话
        Robot robot = new Robot();// 创建Robot对象（机器人）
        robot.delay(3000);// 延迟三秒，主要是为了预留出打开窗口的时间，括号内的单位为毫秒
        Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
//        String[] authors = sentence.split("[,]");// 字符串根据,分割
        for (int j = 0; j < 2; j++) {//循环次数
            for (int i = 0; i < sentence.length; i++) {

                int num = (int) (Math.random() * 26 + 65);
                VK_A = num;

//                String sentencet = sentence[i];


//                Transferable tText = new StringSelection(sentencet);
//                clip.setContents(tText, null);

                // 按下了ctrl+v，完成粘贴功能

//                robot.keyPress(KeyEvent.VK_CONTROL);// 按下Control键
//                robot.keyPress(KeyEvent.VK_V);// 按下V键

                robot.keyPress(KeyEvent.VK_SLASH);// 按下/键
                robot.keyPress(KeyEvent.getExtendedKeyCodeForChar(VK_A));// 随机按下A--Z键
                robot.keyPress(KeyEvent.VK_ENTER);// 回车

//                robot.keyRelease(KeyEvent.VK_CONTROL);// 释放ctrl按键
                robot.delay(500);// 延迟一秒再发送
                robot.keyPress(KeyEvent.VK_ENTER);// 回车

            }
            j = 0;
        }
    }

}
